package com.xzj.admin.boot.controller;

import com.xzj.admin.base.domain.SysMenuInfo;
import com.xzj.admin.base.domain.SysUserInfo;
import com.xzj.admin.boot.service.SystemService;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Tag(name="登录功能")
@RequestMapping("/system")
public class SystemController {

    @Resource
    private SystemService systemService;

    /**
     * 根据用户名获取用户信息
     * @author XiaZunJun
     * @date 2024/6/27 上午11:22
     * * @param username
     * * @return SysUserInfo
     */
    @GetMapping("/userInfoById/{userId}")
    public SysUserInfo userInfoById(@PathVariable(name = "userId") String userId){
        return systemService.userInfoById(userId);
    }

    /**
     * 根据用户名获取用户信息
     * @author XiaZunJun
     * @date 2024/6/27 上午11:22
     * * @param username
     * * @return SysUserInfo
     */
    @GetMapping("/userInfoByName/{username}")
    public SysUserInfo userInfoByName(@PathVariable(name = "username") String username){
        return systemService.userInfoByName(username);
    }

    /**
     * 获取当前用户的菜单
     * @author XiaZunJun
     * @date 2024/6/27 上午11:21
     * * @param userId
     * * @return List<SysMenuInfo>
     */
    @GetMapping("/menuList/{userId}")
    public List<SysMenuInfo> menuList(@PathVariable(name = "userId") String userId){
        return systemService.menuList(userId);
    }

    /**
     * 获取当前用户的菜单
     * @author XiaZunJun
     * @date 2024/6/27 上午11:21
     * * @param userId
     * * @return List<SysMenuInfo>
     */
    @GetMapping("/perCodeList/{userId}")
    public List<String> perCodeList(@PathVariable(name = "userId") String userId){
        return systemService.perCodeList(userId);
    }

}
